***************** Replication of Franchino, Fabio, and Camilla Mariotto. “Bargaining Outcomes and Success in EU Economic Governance Reforms”. Political Science Research and Methods.

* Step 1 to reproduce Figure A4

version 16

******************************* SENSITIVITY ANALYSIS
*************   COMPUTING POINT PREDICTIONS: PROC - Procedural model solutions with reference point
clear all
gen mad=.
save mad_PROCrp.dta, replace

set seed 1234

local v = 0
while `v' <= 1000 {
* Upload original dataset
use PROCmodel_data.dta, clear
gsort issue_id cntry_pos
* Modify 20% of actors's positions
/* We test for unsystematic mis-categorization following the re-categorization test proposed by Eric Neumayer and Thomas Plümper.
We have drawn a random sample of twenty percent of the positions. We have then increased by 25 points the position for half of these cases (if it is not located on upper bound) and decreased by 25 points the other half (if it is not located on the lower bound).
We have then estimated the model outcomes. The procedure is repeated for 1,000 samples
*/
***** Select a random sample without replacement of observations
***** change 4 out of 35 obs by 25 points (half increases and half decreases)
*randomly select 6 issues for commission 
generate random = runiform()
by issue_id, sort: egen random_m = mean(random)
sort country random_m
gen selected_issue=issue_id in 1/4
scalar i1=selected_issue in 1
scalar i2=selected_issue in 2
scalar i3=selected_issue in 3
scalar i4=selected_issue in 4
display i1 " " i2 " " i3 " " i4
do meaningful_shift_commPROC.do
drop random random_m selected_issue

*randomly select 4 issues for parliament 
generate random = runiform()
by issue_id, sort: egen random_m = mean(random)
sort country random_m
gen selected_issue=issue_id in 1/4
scalar i1=selected_issue in 1
scalar i2=selected_issue in 2
scalar i3=selected_issue in 3
scalar i4=selected_issue in 4
display i1 " " i2 " " i3 " " i4
do meaningful_shift_ep_1PROC.do
drop random random_m selected_issue

*randomly change country positions
generate random = runiform()
sort random
do meaningful_shift_cntry_posPROC.do
drop random

* Compute PROC equilibrium outcomes and absolute differences between outcomes and model predictions
do PROCrp_step1.do

* Compute means of absolute differences between outcomes and model predictions
collapse mad
label variable mad "mean of absolute differences" 
append using mad_PROCrp.dta
save mad_PROCrp.dta, replace
sleep 200
local v = `v' + 1
}

use mad_PROCrp.dta, clear
mean mad 
kdensity mad, nor normopts(lwidth(vvthin)) graphregion(fcolor(white)) legend(off) graphregion(fcolor(white)) ytitle("") xtitle("") text(0.075 25 "mean 35.9" "s.e. 0.1", size(small) place(e)) title("PROC", size(small)) note("") ylabel(,labsize(small)) xlabel(,labsize(small)) saving(PROCrp, replace)

